package com.clearliang.alarmnotice.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.CountDownTimer;
import android.support.v7.app.AlertDialog;
import android.view.WindowManager;
import android.widget.Toast;

import com.blankj.utilcode.util.LogUtils;
import com.clearliang.alarmnotice.service.StartAlarmService;

/**
 * Created by ClearLiang on 2019/2/27
 * <p>
 * Function :
 */
public class AlarmReceiver extends BroadcastReceiver {

    public static final String BC_ACTION = "com.ex.action.BC_ACTION";
    public static final String BC_ACTION_CLONE = "com.ex.action.BC_ACTION_CLONE";

    @Override

    public void onReceive(Context context, Intent intent) {
        if (BC_ACTION.equals(intent.getAction())) {
            String msg = intent.getStringExtra("msg");
            LogUtils.e("get Receiver msg :" + msg);
            Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
            // 开启任务
            Intent intent1 = new Intent(context, StartAlarmService.class);
            context.startService(intent1);
        }else if(BC_ACTION_CLONE.equals(intent.getAction())){
            String msg = intent.getStringExtra("msg");
            LogUtils.e("get Receiver msg :" + msg);
            Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
            // 关闭服务
            Intent intent1 = new Intent(context, StartAlarmService.class);
            context.stopService(intent1);
        }
    }
}
